import React, { useRef } from "react";

export default function UnControl () {
  const inputRef = useRef<HTMLInputElement>(null)

  const handleSubmit = (e: React.FormEvent) => {
    e.preventDefault()
    if (inputRef.current) {
      console.log(`输入的值： ${inputRef.current.value}`)
    }
  }

  return (
    <form onSubmit={handleSubmit}>
      <input type="text" defaultValue="初始值" ref={inputRef} />
      <button type="submit">提交</button>
    </form>
  )
}
